<?php

    class CommonController extends Controller
    {
        /**
        * http://hangve.vn/common/imageThumb?path=h.jpg
        * 
        * @param mixed $path
        * @param mixed $w
        * @param mixed $h
        */
        public function actionImageThumb($path, $w = 120, $h = 90){
            Yii::import('ext.wideimage.lib.WideImage');   
            $img = WideImage::load($path);


            // fix with and crop height
//            $img = $img->resize($w, NULL, 'outside', 'down');
//            $img = $img->crop('center', 'center', $w, $h);
//            $img->output('jpg', 90);
            
                                           
            // fix height and crop width         
            $img = $img->resize(NULL, $h, 'outside', 'down');
            $img = $img->crop('center', 'center', $w, $h);
            $img->output('jpg', 90);



//            $img = $img->resize($w, $h, 'outside', 'down');
//            $img = $img->resizeCanvas($w, $h,'center','center', null, 'down');
//            $img->output('jpg', 90);
        }
    }
